1. Field of the Invention
The present invention relates to an image processing apparatus, an imaging apparatus, and an image processing method for generating a cumulative histogram from a histogram of an image and executing gradation conversion processing for performing histogram smoothing.
2. Description of the Related Art
Conventionally, gradation conversion processing in which a cumulative histogram is generated from a histogram of an image and histogram smoothing is executed is known. When the gradation conversion processing is to be executed in an imaging apparatus such as a camera, a histogram is generated with gradations smaller than the number of gradations of an input image using a reduced image, that is, 8 gradations or 16 gradations, for example, and smoothing is performed in order to facilitate processing.
However, if the number of gradations is reduced, when exposure is changed such as a scene change and exposure correction, the histogram is rapidly changed. Particularly, with a flat subject in which the histograms concentrate on a specific gradation, brightness of an image after histogram smoothing becomes brighter or darker, which appears to be an uneven image.
This point will be described by using FIGS. 16A, 16B, 17A, and 17B. In FIGS. 16A and 16B, a pixel value of a reduced image is indicated on a lateral axis, and the gradations are divided into eight parts in this example. If the pixel value is 0 to 4095, for example, a range from 0 to 512 is set to the gradation “0”, a range from 512 to 1024 to the gradation “1”, and a range from 1024 to 1536 to the gradation “3”. Subsequently, they are divided into the gradations “4” to “8” at equal intervals.
In the example in FIGS. 16A and 16B, in the case of a subject of a single plane with uniform brightness over the entire plane, as illustrated in FIG. 16A, the histogram concentrates on a specific gradation. In histogram generating, if the pixel value is contained in a specific range, it is counted as a frequency value of the gradation. That is, in the example illustrated in FIG. 16A, the gradation is divided into 8 gradations from 0 to 7 as described above, and in this example, concentration is found on a gradation n=3.
That is, as illustrated in FIG. 16B, even if the pixel value is V1, V2 or V3, 1 is added to the frequency value of the gradation (n=3) similarly for them all. Thus, in the subject of the single plane with uniform brightness over the entire plane, if further exposure change occurs and the pixel value gradually changes from V1 to V4, the histogram is rapidly switched. That is, for the exposure change from the pixel values V1 to V3, the histogram is not changed (see FIGS. 17A to 17C), but for the exposure change from the pixel values V3 to V4, the histogram is rapidly switched (see FIGS. 17C and 17D). As a result, a rapid change has occurred in the histogram smoothing using the histogram.
Thus, in Japanese Patent No. 5486791 (hereinafter referred to as Patent Literature 1), in frequency value counting at generation of a histogram, such a proposal is made that a weight according to the position in the applicable gradation is calculated and is distributed to the adjacent gradations so as to smoothen a change of the histogram at the exposure change even though the number of gradations is small.
Specifically, on the basis of a pixel value and a relative position in the gradation in which the pixel value is included, a weight as illustrated in FIGS. 18A to 18C is given and distributed to the preceding and subsequent gradations, and the frequency value is counted. A curved line W10 illustrated in FIG. 18A indicates a weight to the frequency value at the corresponding gradation position (n), a curved line W11 illustrated in FIG. 18B indicates a weight to the frequency value at an adjacent position (n−1) of the corresponding gradation position (n), and a curved line W12 illustrated in FIG. 18C indicates a weight to the frequency value of the adjacent position (n+1) of the corresponding gradation position (n).
By giving such weights, as illustrated in FIGS. 19A to 19D, the histogram changes with the exposure change and shows a smooth change. FIG. 19A illustrates a histogram in the case of the pixel value V1 of the reduced image, FIG. 19B shows a histogram in the case of the pixel value V2 of the reduced image, FIG. 19C shows a histogram in the case of the pixel value V3, and FIG. 19D shows a histogram in the case of the pixel value V4 of the reduced image.
By executing the gradation conversion processing proposed in the aforementioned Patent Literature 1, the rapid change of the histogram itself is improved as illustrated in FIGS. 19A to 19D. However, it is insufficient to stably change the result of the histogram smoothing, and brightness of the image of the histogram smoothing can change depending on conditions.
This point will be described by using FIGS. 19E to 19H. Each graph illustrated in FIGS. 19E to 19H shows a cumulative histogram using the histogram in FIGS. 19A to 19D and a state in which the histogram smoothing is performed by using the cumulative histogram as input/output characteristics. Input data shown in lateral axes of the FIGS. 19E to 19H (bidirectional arrows) gradually darkens without any change in a width even if the exposure is changed, while it is found that, in output data after the histogram smoothing shown on a vertical axes (bidirectional arrows), the width is largely changed by the exposure change. That is, in the gradation conversion processing illustrated in Patent Literature 1, a stable result cannot be obtained when local gradation conversion processing using the histogram smoothing is executed. A vertical line close to the center of the bidirectional arrow on the lateral axis indicates an average value.